package com.hulk.Idempotent.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * Created hulk  on 2019/05/28.
 * Content :锁类型
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum LimitType {
    /**
     * 简单
     */
    SIMPLE("com.hulk.limitb.util.SimpleLimitStrategy"),
    /**
     * redis
     */
    REDIS("com.hulk.limitb.util.RedisLimitStrategy"),;


    private String clazz;

    public static LimitType getEnum(String name) {
        LimitType resultEnum = null;
        LimitType[] ProfileAry = LimitType.values();
        for (int i = 0; i < ProfileAry.length; i++) {
            if (Objects.equals(ProfileAry[i].name(),name)) {
                resultEnum = ProfileAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static String getClazz(String name) {
        for (LimitType obj : LimitType.values()) {
            if (Objects.equals(name, obj.name())) {
                return obj.clazz;
            }
        }
        return null;
    }

}
